package com.example.konwRice.DB;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

/**
 * @Author: Stars
 */
public class DBCreater extends SQLiteOpenHelper {
    public static int DATABASE_VERSION = 1 ;
    public static final String DATABASE_NAME="RiceKnow.db";//数据库名称
    public DBCreater(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, DATABASE_NAME, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String CREATE_TABLE_HISTORY=
                "CREATE TABLE if not exists history (" +
                        "_id INTEGER PRIMARY KEY AUTOINCREMENT," +
                        "title int," +
                        "url TEXT, " +
                        "imageUrl int)";

        db.execSQL(CREATE_TABLE_HISTORY);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS collection");
        onCreate(db);
    }
}
